package com.easycoding.framework.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.jdom.Document;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
/**
 * Ext通用方法
 * @editor wangjk
 *
 */
public class ExtUtil {
	/**
	 * 输出结果到页面上
	 * @param response
	 * @param content 将要输出的内容
	 * @throws IOException
	 */
	public static void printResult(HttpServletResponse response, Object content) throws IOException{
		response.setContentType("application/json; charset=GBK");
		PrintWriter out = response.getWriter();
		out.print(content);
		out.flush();
		out.close();
	}
	
	public static void printXmlResult(HttpServletResponse response,Document doc) throws IOException{
		XMLOutputter outputter = new XMLOutputter(); 
		Format f = Format.getPrettyFormat();
        //f.setEncoding("UTF-8");//default=UTF-8
		outputter.setFormat(f); 
		outputter.output(doc, response.getOutputStream());	
	}
}
